//
//  UITabBarController+barStyle.m
//  乡易秀商户端
//
//  Created by delicious on 17/9/2.
//  Copyright © 2017年 chen. All rights reserved.
//

#import "UITabBarController+barStyle.h"

@implementation UIColor (CreateImage)

- (UIImage *)imageWithFrame:(CGRect)frame {
    
    UIImage *image = nil;
    
    if (self) {
        
        UIView *view         = [[UIView alloc] initWithFrame:frame];
        view.backgroundColor = self;
        
        UIGraphicsBeginImageContext(view.frame.size);
        [[view layer] renderInContext:UIGraphicsGetCurrentContext()];
        image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    }
    
    return image;
}

@end


@implementation UITabBarController (barStyle)

-(void)setTabBarBarStyleType:(ETabBarControllerStyle)style {
    
    if (style == kDefaultStyle) { // 系统默认的style
        
        self.tabBar.barStyle = UIBarStyleDefault;
        
    } else if (style == kBlackStyle) {  // 系统的 UIBarStyleBlack
        
        self.tabBar.barStyle = UIBarStyleBlack;
        
    } else if (style == kWhiteColorStyle) { // The tint color to apply to the tab bar background.
        
        self.tabBar.barTintColor = [UIColor whiteColor];
        
    } else if (style == kCustomStyle) { // 自定义 the tab bar background,且没有线条
        
        UIImage *backgroundImage = [[[UIColor colorWithHexString:@"93c86a"] colorWithAlphaComponent:0.85f] imageWithFrame:CGRectMake(0, 0, 10, 10)];
        UIImage *shadowImage     = [[UIImage alloc] init];
        self.tabBar.backgroundImage = backgroundImage;
        self.tabBar.shadowImage     = shadowImage;
    }
}

@end

